<%@ page import="java.util.Map" %>
<%@ page import="Com.javaserver.utils.DB" %>
<%@ page import="java.util.List" %>


<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>首页</title>
</head>
<body>

<%
    // 判断cookie里有没有token，如果没有说明没登录
    Cookie[] cookies = request.getCookies();
    boolean main = false;
    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if (cookie.getName().equals("TOKEN")) {
                main = true;
            }
        }
    }
    if (!main) {
        session.setAttribute("msg", "请登录");
        response.sendRedirect(request.getContextPath() + "/main.jsp");
        return;
    }
%>


<%
    if (session.getAttribute("msg") != null) {
        out.print("<script> alert('" + session.getAttribute("msg") + "'); </script>");
        session.removeAttribute("msg");
    }
%>

</body>

</html>
